#include<vector>
#include <iostream>
using namespace std;

void bubble_sort(vector<int> &v){
  for (int j=0; j < v.size()-1; j++ ){

   for (int s=0; s < v.size(); s++){
   cout << v[s] << " ";
   }
   cout << endl;

    for (int i=j+1; i < v.size(); i++){
     if (v[j] > v[i]){
     int t=0;
     t=v[i];
     v[i]=v[j];
     v[j]=t;
    }
   }
  }
 }

bool is_sorted(const vector<int> &v){


  for (int j=0; j < v.size(); j++){
  cout << v[j] << " ";
  }
  cout << endl;

 if (v.size()<=1)
  return true;


 for (int j=1; j < v.size(); j++ )
  if(v[j]<v[j-1])
   return false;
 return true;
}

int main (int argc, char ** argu){
vector <int> v;
int z;

  while (1) {
cout << "numbers"<< endl;
  cin >> z;
  if (0==z) break;
  v.push_back(z);
 }

bool b;
b= is_sorted (v);
 cout << b << endl;

 if (b==false)
  bubble_sort (v);

b= is_sorted (v);
 cout << b << endl;

 return 0;
}
